using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using System.Data.Linq;
using System.Linq;
using DataLayer;

namespace BusinessLayer.Activities
{
   public partial class Check_UserTabPermission_TabRead : System.Workflow.ComponentModel.Activity
   {
      public Check_UserTabPermission_TabRead()
      {
         //InitializeComponent();
      }

      private static DependencyProperty TabIdProperty = DependencyProperty.Register("TabId", typeof(int), typeof(Check_UserTabPermission_TabRead));
      public int TabId
      {
         get { return (int)base.GetValue(TabIdProperty); }
         set { base.SetValue(TabIdProperty, value); }
      }

      private static DependencyProperty UserGuidProperty = DependencyProperty.Register("UserGuid", typeof(Guid), typeof(Check_UserTabPermission_TabRead));
      public Guid UserGuid
      {
         get { return (Guid)base.GetValue(UserGuidProperty); }
         set { base.SetValue(UserGuidProperty, value); }
      }

      private static DependencyProperty ResultProperty = DependencyProperty.Register("Result", typeof(bool), typeof(Check_UserTabPermission_TabRead));
      public bool Result
      {
         get { return (bool)base.GetValue(ResultProperty); }
         set { base.SetValue(ResultProperty, value); }
      }

      protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
      {
         if (TabAccessLevelFunctions.UserHasPermission(UserGuid, TabId, TabAccessLevel.Tab_Read))
         {
            Result = true;
         }
         else
         {
            //throw new ApplicationException("You do not have sufficient privilages to perform this operation");
            Result = false;
         }
  
         return ActivityExecutionStatus.Closed;
      }
   }
}